home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boostrs.arc / PUTSTR.ASM < prev    next >
Assembly Source File  |  1985-09-29  |  2KB  |  113 lines

  1. ;*******************************************************
  2. ;       type
  3. ;           AnyString  = string[255];
  4. ;           ColumnType = 0..80;
  5. ;           RowType    = 0..25;
  6. ;
  7. ;       Procedure PUTSTR (     HV : Char;
  8. ;                               S : AnyString;
  9. ;                               X : ColumnType;
  10. ;                               Y : RowType;
  11. ;                       Attribute : byte);
  12. ;*******************************************************
  13. PutStr  proc    near
  14.         push    bp
  15.     mov    bp,sp
  16.     push    ds
  17. ;
  18. ;*** Determine Video address
  19. ;
  20.     mov    bx,449h
  21.     xor    ax,ax
  22.     mov    ds,ax
  23.     mov    al,[bx]
  24.     cmp    al,7
  25.     jne    graphx
  26.     mov    dx,0B000h
  27.     jmp    c001
  28. graphx:
  29.     mov    dx,03DAh    ; for IBM CGA,
  30. VR:    in    al,dx        ; we must do this
  31.     and    al,1000b    ; so we won't see
  32.     jz    vr        ; snow . . . and
  33.     mov    dx,0B800h    ; so long, speed
  34. c001:    mov    es,dx
  35. ;
  36.     mov    bx,[bp+8]    ; X
  37.     or    bx,bx        ; X=0?
  38.     jz    p001
  39. ;
  40. ;       set DH, DL
  41. ;
  42.     dec    bx
  43.     mov    ax,[bp+6]    ; Y
  44.     dec    ax
  45.     mov    dh,al        ; DH=Y
  46.     mov    dl,bl        ; DL=X
  47.     jmp    P002
  48. ;
  49. ;       Get Current Cursor Position
  50. ;
  51. P001:    mov    ah,3
  52.     int    10h
  53. ;
  54. ;       Compute DI offset
  55. ;
  56. P002:    mov    bl,dh        ; Row (Y-1)
  57.     xor    bh,bh
  58.     mov    ax,bx
  59.     mov    cl,7
  60.     shl    ax,cl        ; (Y-1) * 128
  61.     mov    cl,5
  62.     shl    bx,cl        ; (y-1) *  32
  63.     add    bx,ax        ; (y-1) * 160
  64.     mov    al,dl        ; Column (X-1)
  65.     xor    ah,ah
  66.     shl    ax,1        ; 2 * (X-1)
  67.     add    bx,ax        ; BX = offset
  68.     mov    di,bx        ; DI = offset
  69. ;
  70.     mov    cl,[bp+10]    ; length of string
  71.     xor    ch,ch
  72.     or    cx,cx        ; if length is 0,
  73.     jz    return        ; leave PutStr
  74.     lea    si,[bp+11]    ; string offset
  75.     push    ss
  76.     pop    ds
  77.     mov    ah,[bp+4]    ; attribute byte
  78.     mov    dx,[bp+266]    ; direction (H or V)
  79.     cmp    dl,'v'
  80.     je    P003
  81.     cmp    dl,'V'
  82.     je    P003
  83.     xor    dx,dx
  84.     jmp    P003a
  85. P003:    mov    dx,158
  86. P003A:    cld
  87. ;
  88. DO    mov    al,[si]     ; get character
  89.         stosw                    ; store on screen
  90.     add    di,dx
  91.     inc    si
  92.     loop    DO
  93. ;
  94. ;       Set Cursor for exit
  95. ;
  96.     or    dx,dx
  97.     jz    P004
  98.     sub    di,158
  99. P004:    mov    ax,di
  100.     xor    dx,dx
  101.     mov    bx,160
  102.     div    bx
  103.     shr    dl,1
  104.     mov    dh,al
  105.     mov    ah,2
  106.     int    10h
  107. ;
  108. Return: pop    ds
  109.         mov     sp,bp
  110.         pop     bp
  111.     ret    264
  112. PutStr  endp
  113.